package com.briup.monitor;

import com.briup.monitor.listener.NewJNotifyListener;

import net.contentobjects.jnotify.JNotify;

public class JNotifyTest {

	public static void main(String[] args)  throws Exception{
		 // path to watch
	    String path = "C:\\Documents and Settings\\jnian\\Desktop\\test\\";
	    System.out.println("Watch directory: " + path);

	    // watch mask, specify events you care about,
	    // or JNotify.FILE_ANY for all events.
	    int mask = JNotify.FILE_CREATED  | 
	               JNotify.FILE_DELETED  | 
	               JNotify.FILE_MODIFIED | 
	               JNotify.FILE_RENAMED;

	    // watch subtree?
	    boolean watchSubtree = true;

	    // add actual watch
	    int watchID = JNotify.addWatch(path, mask, watchSubtree, new NewJNotifyListener());

	    // sleep a little, the application will exit if you
	    // don't (watching is asynchronous), depending on your
	    // application, this may not be required
	    Thread.sleep(1000000);

	    // to remove watch the watch
	    boolean res = JNotify.removeWatch(watchID);
	    if (!res) {
	      // invalid watch ID specified.
	    }
	  }

	}
